<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>你瞅啥</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <script type="text/javascript" src="libs/handlebars.min.js"></script>
  
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
     <div class="container">
    <div class="row">
      <div class="page-header"><h2><strong>你瞅瞅记账</strong></h2></div>
      <div class="col-md-8">
        <ul class="nav nav-pills">
          <li class=""><a href="index.html">首页</a></li>
          <li><a href="#">用户：<span id="account"></span></a></li>
          <li class=""><a href="shouru.html">添加新的收入</a></li>
          <li class=""><a href="zichu.html">添加新的支出</a></li>
          <li class=""><a href="jizhang.html">添加新的</a></li>
          <li class=""><a href="chaxun.html">统计</a></li>
          <li class="active"><a href="tongji.html">查询</a></li>
        </ul>
      </div>
    </div>
  </div>
  <div class="contrainer">
    <div class="row"><div class=cil-md-12><hr/></div> 
    </div>
  </div>
  <div class="container">
    <div class="row">
      <div class="col-md-4 col-md-offset-1">
          <div class="form-group">
	          <label for="date_time">时间</label>
	          <input type="date" class="form-control" id="date_time"/>
	      </div>
	      <div class="form-group">
	          <label for=place>地点</label>
	          <input type="text" class="form-control" id="place"/>
	      </div>
	      <div class="form-group">
	          <label for="money_in">收入金额</label>
	          <input type="text" class="form-control" id="money_in"/>
		  </div>
		   <div class="form-group">
	          <label for="money_out">支出金额</label>
	          <input type="text" class="form-control" id="money_out"/>
		  </div>
		  <div class="form-group">
	          <label for="kind">收入支出类型</label>
	          <input type="text" class="form-control" id="kind"/>
	      </div>
	      <div class="form-group">
	          <label for="remark">备注</label>
	          <input type="text" class="form-control" id="remark"/>
	      </div>
	      <button id="tongji" class="btn btn-primary btn-block">查询</button>
	    </div>
     <div class="col-md-6">  
      <div class="panel panel-warning">
          <div class="panel-heading"><h4>查询结果</h4></div>
          <div class="panel-body" id="text1"></div>
      </div>
	 </div>
   </div> 
 </div>
 <script id="template" type="text/x-handlebars-template">
  {{#each item}}
  <div class="panel panel-default col-md-4">
    <div class="panel-body"> 
     <dl>
       <dt>时间</dt><dd>{{date_time}}</dd>
       <dt>地址</dt><dd>{{place}}</dd>
       <dt>收入金额</dt><dd>{{money_in}}</dd>
       <dt>支出金额</dt><dd>{{money_out}}</dd>
       <dt>类别</dt><dd>{{kind}}</dd>
       <dt>备注</dt><dd>{{remark}}</dd>
       <a href="queryone.html?id=#{id}">显示详细信息</a>
    </dl>
   </div>
  </div>
 {{/each}}
</script>
 <script type="text/javascript">
 $(function () {
	 $.getJSON('querynickname.action',function(res){
		 console.log(res);
		 $('#account').text(res.nickname);})
	  $('#tongji').click(function (){
	     $.post('TongJi.action', {
	     date_time: $('#date_time').val(),
	     place: $('#place').val(),
	     money_in: $('#money_in').val(),
	     /* money_out: $('#money_out').val(), */
	     kind: $('#kind').val(),
	     remark:$('#remark').val(),
	        },function(res,status){
	     console.log(res);
	     // console.log(status);
	     var date = {'item':res};
	     var t = Handlebars.compile($('#template').html());
	     $('#text1').html(t(date));
	    });
      });
	});

  </script>
   
</body>
</html>